package com.zecan.blog.vo.user;

import com.zecan.blog.entity.BlogUser;
import lombok.Builder;
import lombok.Data;

/**
 * @author zecan
 * @Description:
 * @ClassName: bgUserInfoVo
 * @date 2023/1/13 21:21
 */
@Data
@Builder
public class bgUserInfoVo {

    private Integer userId;

    private String userAvatar;

    private String username;

    private  String userRole;

    private String userEmail;

    private String userRegistryTime;

    private Integer userCount;

    public static bgUserInfoVo bgUserInfoVo(BlogUser blogUser) {
        return bgUserInfoVo.builder()
                .userAvatar(blogUser.getUserAvatarUrl())
                .userRegistryTime(blogUser.getUserRegisterTime())
                .username(blogUser.getUsername())
                .userId(Math.toIntExact(blogUser.getUserId()))
                .userRole(blogUser.getUserRole() == 1 ? "管理员" : "普通用户")
                .userEmail(blogUser.getUserEmail())
                .build();
    }
}
